﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HuntTheWumpuz
{
	class HighScore
	{
		String[] namelist;
		int[] scorelist;
		List<HighScoreData> Highscoreslist = new List<HighScoreData>();

		public HighScore()
		{
			HighScoreData H1 = new HighScoreData("Player", 0, "cave 1");
			Highscoreslist.Add(H1);
			HighScoreData H2 = new HighScoreData("Player", 0, "cave 1");
			Highscoreslist.Add(H1);
			HighScoreData H3 = new HighScoreData("Player", 0, "cave 1");
			Highscoreslist.Add(H1);
			HighScoreData H4 = new HighScoreData("Player", 0, "cave 1");
			Highscoreslist.Add(H1);
			HighScoreData H5 = new HighScoreData("Player", 0, "cave 1");
			Highscoreslist.Add(H1);
			HighScoreData H6 = new HighScoreData("Player", 0, "cave 1");
			Highscoreslist.Add(H1);
			HighScoreData H7 = new HighScoreData("Player", 0, "cave 1");
			Highscoreslist.Add(H1);
			HighScoreData H8 = new HighScoreData("Player", 0, "cave 1");
			Highscoreslist.Add(H1);
			HighScoreData H9 = new HighScoreData("Player", 0, "cave 1");
			Highscoreslist.Add(H1);
			HighScoreData H10 = new HighScoreData("Player", 0, "cave 1");
			Highscoreslist.Add(H1);

			sortlist();
		}

		private void sortlist()
				{
					for (int x = 0; x < Highscoreslist.Count; x++)
					{
						int currentscore = Highscoreslist[x].Score;

						for (int y = x + 1; y < Highscoreslist.Count; y++)
						{
							if (Highscoreslist[y].Score > currentscore)
							{
								HighScoreData ths = Highscoreslist[x];
								Highscoreslist[x] = Highscoreslist[y];
								Highscoreslist[y] = ths;
								currentscore = Highscoreslist[x].Score;
							}
						}
					}
				}

		public void addHighScore()
		{
			int temporaryscore = 0;
			string name = "";
			string cave = "";
			//temporaryscore = 100 - GameControl.mainPlayer.Turns + GameControl.mainPlayer.Gold + (10 * GameControl.mainPLayer.Arrow);

			HighScoreData H1 = new HighScoreData(name, temporaryscore, cave);
			Highscoreslist.Add(H1);

			if (Highscoreslist.Count > 10)
			{
				Highscoreslist.RemoveAt(10);
			}

			sortlist();

		}

		


	}
}
